#ifndef __MOVING_BLOCK_H__
#define __MOVING_BLOCK_H__

#include <mutex>
#include "Engine/Vector3.hpp"
#include "Engine/Vector2.hpp"
#include "Engine/Point3.hpp"
#include "Engine/Box.hpp"
#include "Engine/BoundingBox.hpp"

using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    class BlocksManager;
    class SubsystemTerrain;

    struct MovingBlock
    {
    public:
        Point3 offset;
        int32_t value;
        constexpr inline MovingBlock(const Point3 &theOffset, int32_t theValue) : offset(theOffset), value(theValue) {}
    };

    class MovingBlockSet
    {
    public:
        std::string Id;
        std::shared_ptr<Point3> Tag = nullptr;
        bool Stop = false;                          // 是否停止
        // int32_t RemainCounter;                   // 剩余计数器
        Vector3 Position;                           // 位置
        Vector3 StartPosition;                      // 起点
        Vector3 TargetPosition;                     // 终点
        float Speed;                                // 速度
        float Acceleration;                         // 加速
        float Drag;
        Vector2 Smoothness;
        std::vector<MovingBlock> Blocks;
        std::mutex MovingBlocksMutex;

        Box MovingBox;
        Vector3 CurrentVelocity;

        inline void stop()
        {
            Stop = true;
        }

        void updateBox();

        BoundingBox getBoundingBox(bool extendToFillCells);

        void setBlock(const Point3 &offset, int32_t value);
    };

}

#endif
